package com.smile.commons.request;

import com.alibaba.ttl.TransmittableThreadLocal;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class RequestIdUtils {
    private static TransmittableThreadLocal<String> threadLocal = new TransmittableThreadLocal<>();


    public static void set(String id) {
        try {

            threadLocal.set(id);
        } catch (Exception e) {
            log.error("TransmittableThreadLocal error:", e);
            throw new RuntimeException("TransmittableThreadLocal error:", e);
        }
    }

    public static String get() {
        try {

            return threadLocal.get();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
